home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 439 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  59 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: "nicolas (n.) chapados" <chapados@bnr.ca>
  3. Newsgroups: comp.std.c++
  4. Subject: Template specialization with template?
  5. Date: 22 Feb 1996 09:13:53 PST
  6. Organization: Bell Northern Research
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <312BF6A1.5BBE@bnr.ca>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Original-Date:  Wed, 21 Feb 1996 23:52:49 -0500 
  14. Content-Identifier:  Template spec... 
  15. X-Mailer: Mozilla 2.0 (Win95; I) 
  16. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  17.     iQBVAwUBMSykXUy4NqrwXLNJAQEfegIAtmRgTf+AS0rS1Wj3HhbRO0k/JLo8EURE
  18.     OPaYHx3kavfQdJ0N9bdPxNFG6OuGMywL0ladmVywBpemkHc691d5RQ==
  19.     =sSL+
  20. Originator: austern@isolde.mti.sgi.com
  21.  
  22. It sometimes would be useful to have a template specialization be
  23. itself a template.  For example, to define persistent I/O on all
  24. vectors of type T, one could specialize PersistentIO<T>:
  25.  
  26.     template <class T>
  27.     class PersistentIO< vector<T> >
  28.     { ... };
  29.  
  30. I'd like to know whether this is allowed by the current draft.
  31. Given the affirmative, what does the T argument represent inside
  32. the specialization?
  33.  
  34. An alternative, which is not unfortunately not supported, would be
  35. to define a specialization as a friend inside vector<T>:
  36.  
  37.     template <class T>
  38.     class Vector<T> {
  39.     public:
  40.         // ...
  41.         friend class PersistentIO< vector<T> >
  42.         { ... };
  43.     };
  44.  
  45. Could someone enlighten me as to why it is not permitted to define
  46. a friend class inside another class, whereas defining a friend
  47. inline function in a class is perfectly acceptable (and very useful
  48. when used with templates)?
  49.  
  50.     Nicolas Chapados
  51.     chapados@bnr.ca
  52. ---
  53. [ To submit articles: Try just posting with your newsreader.  If that fails,
  54.                       use mailto:std-c++@ncar.ucar.edu
  55.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  56.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  57.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  58. ]
  59.